import {clearStorage, getStorage, setStorage} from "@/utils/storage";

const userState = {
    token: null
}
const userGetters = {
    token: (state: any) => state.token
}
const userMutations = {
    SET_TOKEN(state: any, val: string) {
        state.token = val
        setStorage("token", val)
    },
    GET_TOKEN(state: any) {
        if (getStorage("token")) {
            state.token = getStorage("token")
        }
    },
    CLEAR_TOKEN(state: any) {
        state.token = null
        clearStorage("token")
    }
}
const userActions = {}

export {
    userState, userGetters, userMutations, userActions
}
